#/bin/bash

LROOT=$PWD
JOBCOUNT=${JOBCOUNT=$(nproc)}
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

cd linux-6.8.1/

#
#case 1 - normal build
#

# {
#     make mrproper
#     make defconfig
#     make modules_prepare
#     make -j$(nproc)
# }

#
#case 2 - build output to a folder
#

make mrproper

export INSTALL_PATH=$LROOT/rootfs_debian_arm64/boot/
export INSTALL_MOD_PATH=$LROOT/rootfs_debian_arm64/
export INSTALL_HDR_PATH=$LROOT/rootfs_debian_arm64/usr/
export BUILD_OUTPUT=$LROOT/build_output

echo "install path: " $INSTALL_PATH

echo "build output: " $BUILD_OUTPUT

rm -rf $BUILD_OUTPUT
mkdir -p $BUILD_OUTPUT
make defconfig O=$BUILD_OUTPUT

make menuconfig O=$BUILD_OUTPUT

make O=$BUILD_OUTPUT -j $JOBCOUNT

# TODO: can't execute in ARM64....
make O=$BUILD_OUTPUT modules_prepare

cd $BUILD_OUTPUT

make modules_install -j $JOBCOUNT
make install


